package com.hainatong.jcmvvmbase.mainhome.fragment;

import android.os.Bundle;
import android.view.View;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.hainatong.jcmvvmbase.Constants;
import com.hainatong.jcmvvmbase.MvvmLazyFragment;
import com.hainatong.jcmvvmbase.R;
import com.hainatong.jcmvvmbase.databinding.FragmentRukuTaskBinding;
import com.hainatong.jcmvvmbase.mainhome.ComFragmentActivity;
import com.hainatong.mvvmbase.base.NoViewModel;

public class RukuTaskFragment extends MvvmLazyFragment<FragmentRukuTaskBinding , NoViewModel>
{
    private static String RUKU_TASK_TAG = "RukuTaskFragment";

    private String goodsCode ;

    public static RukuTaskFragment newInstance(String scanCode)
    {
        Bundle bundle = new Bundle();
        bundle.putString( RUKU_TASK_TAG , scanCode );
        RukuTaskFragment taskFragment = new RukuTaskFragment();
        taskFragment.setArguments( bundle );
        return taskFragment;
    }

    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_ruku_task;
    }

    @Override
    public int getBindingVariable() {
        return 0;
    }

    @Override
    protected void initParameters()
    {
        Bundle args = getArguments();
        if(  args != null )
        {
            goodsCode = args.getString(RUKU_TASK_TAG , "");
        }
    }

    @Override
    protected void onRetryBtnClick()
    {
    }

    @Override
    protected void initView(View view)
    {
        viewDataBinding.btnAddToShelf.setOnClickListener( v -> {

            // 跳转 添加  列表
            Bundle bundle = new Bundle();
            bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_TYPE_RUKU_ADD);
            bundle.putString( Constants.SCAN_CONTENT_CODE, goodsCode);
            ComFragmentActivity.start( getActivity(),bundle );

        } );

        viewDataBinding.btnBroken.setOnClickListener( v -> {

            // 跳转 破损提交
            Bundle bundle = new Bundle();
            bundle.putString( Constants.FRAGMNET_TYPE, Constants.VIEW_TYPE_BROKEN_SUB);
            bundle.putString( Constants.SCAN_CONTENT_CODE, goodsCode);
            ComFragmentActivity.start( getActivity(),bundle );


        } );
    }

    @Override
    protected void lazyLoad()
    {
        if(!StringUtils.isEmpty( goodsCode ))
        {
            ToastUtils.showShort(goodsCode);
        }
    }
}
